/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddItemDialog.java
 *
 * Created on 08.03.2010, 19:07:07
 */

package org.bizon.dinner.gui.dialogs;

import org.bizon.dinner.gui.topcompoments.AdminTableModel;

/**
 * 
 * @author Bizon
 */
public class AddItemDialog extends javax.swing.JDialog {

	private static final long serialVersionUID = 7228963624624072672L;
	private AdminTableModel model;

	/** Creates new form AddItemDialog */
	public AddItemDialog(java.awt.Frame parent, boolean modal, AdminTableModel model) {
		super(parent, modal);
		this.model = model;
		initComponents();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		itemLabel = new javax.swing.JLabel();
		priceLabel = new javax.swing.JLabel();
		nameTextField = new javax.swing.JTextField();
		priceTextField = new javax.swing.JFormattedTextField();
		okButton = new javax.swing.JButton();
		cancelButton = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

		itemLabel.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.itemLabel.text")); // NOI18N

		priceLabel.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.priceLabel.text")); // NOI18N

		nameTextField.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.nameTextField.text")); // NOI18N

		priceTextField.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.priceTextField.text")); // NOI18N

		okButton.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.okButton.text")); // NOI18N
		okButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				okButtonActionPerformed(evt);
			}
		});

		cancelButton.setText(org.openide.util.NbBundle.getMessage(AddItemDialog.class, "AddItemDialog.cancelButton.text")); // NOI18N
		cancelButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				cancelButtonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addGroup(
						layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addGroup(
								layout.createSequentialGroup().addComponent(itemLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(nameTextField)).addGroup(
								layout.createSequentialGroup().addComponent(priceLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addGroup(
														layout.createSequentialGroup().addComponent(okButton).addPreferredGap(
																javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton)).addComponent(
														priceTextField)))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addGroup(
						layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(itemLabel).addComponent(nameTextField,
								javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(
								layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(priceLabel).addComponent(priceTextField,
										javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(
								layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(okButton).addComponent(cancelButton))
						.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_okButtonActionPerformed
		setVisible(false);
		model.addItem(nameTextField.getText(), priceTextField.getText());
	}// GEN-LAST:event_okButtonActionPerformed

	private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_cancelButtonActionPerformed
		setVisible(false);
	}// GEN-LAST:event_cancelButtonActionPerformed

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton cancelButton;
	private javax.swing.JLabel itemLabel;
	private javax.swing.JTextField nameTextField;
	private javax.swing.JButton okButton;
	private javax.swing.JLabel priceLabel;
	private javax.swing.JFormattedTextField priceTextField;
	// End of variables declaration//GEN-END:variables

}
